<?php

/**************************************************************************************************************************
 *                                                      === XERO ===                                                      *
 *                                                  hello.xero@gmail.com                                                  *
 * We provide a FREE software consultancy and development service to ensure that your ideas will be realized.             *
 * Gurus in C++ / C / (ARM, Z80, Intel, 68K) Assembler / LISP / LUA / Smalltalk / PHP / Java / Symbian / Windows /        *
 * Linux / Kernels / Architecture / API design / Penetration / Protection / Graphics / Audio                              *
 **************************************************************************************************************************/


/**
 * Performs initialization.
 * @author XERO
 */

// Constants
define('DS', DIRECTORY_SEPARATOR);

// Directories
define('ROOT', str_replace('/', DS, dirname($_SERVER['DOCUMENT_ROOT'])));
define('PRIVATE_DIR', ROOT . DS . 'private');
define('CLASS_DIR', PRIVATE_DIR . DS . 'classes');

// Database
define('DB_HOST', 'localhost');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', '123456789');

set_include_path(get_include_path() . PATH_SEPARATOR . PRIVATE_DIR);

// Load utility functions
require_once 'utils.php';

// Initialize auto class loaders - ignore error codes
spl_autoload_register();
spl_autoload_register('autoload');


/**
 * Autoload classes
 *
 * @param unknown_type $aClass
 */
function autoload($aClass)
{
    try {
        // The php file must have the same name as the class
        include_once CLASS_DIR . DS . $aClass . '.php';
        return $aClass;
    } catch (Exception $e) {
        // Can't throw an exception from the auto loader.
        // You'd normally log the exception here ;-)
    }
    return false;
}
